#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
int T;
ll n,m;
ll a[N],b[N];
bool check(ll mid,ll m){
    ll s=0;
    ll now=(mid+a[0]-1)/a[0];
    ll nex=(mid+a[1]-1)/a[1];
    for(int i=0;i<n-1;i++){
        s++;
        now--;
        if(now>0){
            s+=2*now;
            nex-=now;
            if(s>m){
                return false;
            }
        }
        now=nex;
        if(a[i+2]!=0){
            nex=(mid+a[i+2]-1)/a[i+2];
        }
    }
    if(now>0){
        s++;
        now--;
        s+=2*now;
    }
    return s<=m;
}
int main(void){
    scanf("%d",&T);
    while(T--){
        scanf("%lld%lld",&n,&m);
        for(int i=0;i<n;i++){
            scanf("%lld",&a[i]);
        }
        //printf("%d\n",check(22,m));
        ll l=0,r=1e18;
        ll mid;
        ll ans=0;
        while(l<=r){
            mid=l+(r-l)/2;
            //printf("%lld %lld %lld\n",l,mid,r);
            if(check(mid,m)){
                l=mid+1;
                ans=max(ans,mid);
            }else{
                r=mid-1;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}